package com.zatech.cgnci.project.service.impl;

import com.zatech.cgnci.project.base.context.UserContext;
import com.zatech.cgnci.project.base.utils.ConvertUtils;
import com.zatech.cgnci.project.dto.PaymentInformationAddDTO;
import com.zatech.cgnci.project.dto.PaymentInformationUpdateDTO;
import com.zatech.cgnci.project.entity.CgnciPaymentInformationDO;
import com.zatech.cgnci.project.entity.UserEntity;
import com.zatech.cgnci.project.mapper.CgnciPaymentInformationMapper;
import com.zatech.cgnci.project.service.CgnciPaymentInformationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zatech.cgnci.project.vo.CgnciPaymentInformationVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 收款信息表 服务实现类
 * </p>
 *
 * @author Generator
 * @since 2025-01-15
 */
@Service
public class CgnciPaymentInformationServiceImpl extends ServiceImpl<CgnciPaymentInformationMapper, CgnciPaymentInformationDO> implements CgnciPaymentInformationService {


    @Override
    public Long addPaymentInformation(PaymentInformationAddDTO addDTO) {
        UserEntity user = UserContext.getUser();
        CgnciPaymentInformationDO paymentInformationDO = ConvertUtils.convert(addDTO,CgnciPaymentInformationDO.class);
        paymentInformationDO.setCreateUser(user.getNameAndCode());
        this.baseMapper.insert(paymentInformationDO);
        return paymentInformationDO.getId();
    }

    @Override
    public void deletePaymentInformation(Long id) {
        this.baseMapper.deleteById(id);
    }

    @Override
    public void updatePaymentInformation(PaymentInformationUpdateDTO updateDTO) {
        CgnciPaymentInformationDO paymentInformationDO = ConvertUtils.convert(updateDTO,CgnciPaymentInformationDO.class);
        UserEntity user = UserContext.getUser();
        paymentInformationDO.setUpdateUser(user.getNameAndCode());
        this.baseMapper.updateById(paymentInformationDO);
    }

    @Override
    public List<CgnciPaymentInformationVO> queryPaymentInformationByNumber(Long statementNumber) {
        return this.baseMapper.queryPaymentInformationByNumber(statementNumber);
    }
}
